#include "enemy4.h"
#include"config.h"
#include"widget.h"
enemy4::enemy4()
{
    m_enemy4.load(ENEMY_PATH4);
    m_enemy3.load(NOMOVE);
    //
    m_X=0;
    m_Y=0;
    //
    m_Free=true;
    //
    m_Speed=ENEMY_SPEED4
    //
    m_Rect.setWidth(m_enemy4.width()-30);
    m_Rect.setHeight(m_enemy4.height()-30);
    m_Rect.moveTo(m_X,m_Y);
}

void enemy4::updatePosition()
{
    if(m_Free){
        return;
    }
    m_Y+=m_Speed;
    m_Rect.moveTo(m_X,m_Y);
    //
    if(m_Y>=GAME_HEIGHT+m_Rect.height()){
        m_Free=true;}
}

void enemy4::shoot4()
{
    //累加时间间隔记录变量
   record++;
    m_recorder++;
        // 如果记录数字未达到时间间隔，直接return，不发射子弹
    if(record==BOSS_TIME)   {
    if(m_recorder<BULLET_INTERVAL1){
            return;
        }
        //达到发射时间
        m_recorder=0;
        record=0;
        //发射子弹
        for(int i=0;i<BULLET_NUM1;i++){
            //如果子弹空闲，发射
            if(m_bullet1[i].m_Free){
                //将子弹空闲状态改为假
                m_bullet1[i].m_Free=false;
                //设置子弹坐标
               /* m_bullet[i].m_X=m_X;
                m_bullet[i].m_Y=m_Y;  存在偏差*/


                m_bullet1[i].m_X=235;
                m_bullet1[i].m_Y=40;
                break;
            }
        }
}
}

